package csc.daonjpa.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;

import csc.daonjpa.java.beans.CustomerBean;
import csc.daonjpa.java.service.CustomerService;

@Controller
//@SessionAttributes({ "user", "roleuser" })
public class LoginController {
	
	@Autowired
	CustomerService customerService;
	
	public CustomerService getCustomerService() {
		return customerService;
	}

	public void setCustomerService(CustomerService customerService) {
		this.customerService = customerService;
	}

	@RequestMapping( value = "/login", method = RequestMethod.GET)
	public String doLogin() {
		return "login";
	}
	
	@RequestMapping( value = "/checkLogin/{username}/{password}", method = RequestMethod.POST)
	public String checkLogin(@PathVariable("username") String username, @PathVariable("password") String password) {
		CustomerBean cus = new CustomerBean();
		cus.setLoginId(username);
		cus.setPassword(password);
		
		System.out.println(username + " " + password);
		return "home";
		
//		if (customerService.authentication(cus)) {
//			return "forward:getAccountList";
//		}
//		return "login";
	}
	
}
